05057b4dadde7e5b4e2dc7de0e6e7bc2a3d72f7b,src/main/java/com/treasure_data/logger/sender/HttpClient.java,HttpClient,createDatabase,#String#,104
Before Change
public boolean createDatabase(String databaseName) throws IOException, APIException {
String path = String.format("/v3/database/create/%s", new Object[] { databaseName });
HttpURLConnection conn = doPostRequest(path, null, null);
int code = getResponseCode(conn);
if (code != HttpURLConnection.HTTP_OK) { // not 200
String msg = String.format("Create database failed (%d: %s)",
new Object[] { code, getResponseMessage(conn) });
LOG.error(msg);
disconnect(conn);
throw new APIException(msg);
}
return true;
}
public Map<String, Table> getTables(String databaseName) throws IOException, APIException {
After Change
HttpURLConnection conn = null;
try {
String path = String.format("/v3/database/create/%s", new Object[] { name });
conn = doPostRequest(path, null, null);
int code = getResponseCode(conn);
if (code != HttpURLConnection.HTTP_OK) {
String msg = String.format("Create database failed (%s (%d): %s)",
new Object[] { getResponseMessage(conn), code, getResponseBody(conn) });
LOG.error(msg);
throw new APIException(msg);
}
} catch (IOException e) {
throw new APIException(e);
} finally {
if (conn != null) {
disconnect(conn);
}
}
return true;
}
public Map<String, Table> getTables(String name) throws APIException {